package com.jianan.mis.data.domain;

import java.util.HashSet;
import java.util.Set;

/**
 * 会话状态
 * 
 * @author hp
 * 
 */
public class Session {

	// 登陆员工的编号
	private Integer employeeId;
	
	// 登陆员工的名字
	private String employeeName;

	// 员工的组别
	private Set<String> groups = new HashSet<String>();

	private static Session INSTANCE;

	private Session() {
	}

	// 单例模式
	public static Session getInstance() {
		if (INSTANCE == null) {
			INSTANCE = new Session();
		}
		return INSTANCE;
	}

	public Integer getEmployeeId() {
		return employeeId;
	}

	public String getEmployeeName() {
		return employeeName;
	}

	public Set<String> getGroups() {
		return groups;
	}

	public void setEmployee(Employee employee) {
		employeeId = employee.getId();
		employeeName = employee.getName();
		if (employee.getGroups() != null) {
			for (Group group : employee.getGroups()) {
				groups.add(group.getCode());
			}
		}
	}
}
